<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>Introduction_to_Algorithms: src/graph_algorithms/max_flow/ford_fulkerson/fordfulkerson.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Introduction_to_Algorithms
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('fordfulkerson_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">fordfulkerson.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="fordfulkerson_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Copyright 2016- huaxz &lt;huaxz1986@163.com&gt;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * This program is free software: you can redistribute it and/or modify</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * it under the terms of the GNU General Public License as published by</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * the Free Software Foundation, either version 2 of the License, or</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * (at your option) any later version.</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * This program is distributed in the hope that it will be useful,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * GNU General Public License for more details.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * You should have received a copy of the GNU General Public License</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * Author: huaxz1986@163.com (huaxz)</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#ifndef FORDFULKERSON</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="preprocessor">#define FORDFULKERSON</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#include&lt;memory&gt;</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">#include&lt;array&gt;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#include&lt;vector&gt;</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#include&lt;functional&gt;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include&quot;<a class="code" href="header_8h.html">src/header.h</a>&quot;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include&quot;../../basic_graph/graph_bfs/bfs.h&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespace_introduction_to_algorithm.html">IntroductionToAlgorithm</a></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;{</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    <span class="keyword">namespace </span>GraphAlgorithm</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    {</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        <span class="keyword">template</span>&lt;<span class="keyword">typename</span> GraphType&gt; std::shared_ptr&lt;GraphType&gt;</div>
<div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#acc8cd65d7cf2d584f86cfd92494bdbf4">   54</a></span>&#160;            <a class="code" href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#acc8cd65d7cf2d584f86cfd92494bdbf4">create_Gf</a>(<span class="keyword">const</span> std::shared_ptr&lt;GraphType&gt; graph,</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;                      std::array&lt;std::array&lt;typename GraphType::EWeightType,GraphType::NUM&gt;,GraphType::NUM&gt;&amp;flow)</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        {</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;            <span class="keyword">typedef</span> <span class="keyword">typename</span> GraphType::EdgeTupleType EdgeTupleType;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;            <span class="keywordflow">if</span>(!graph)</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;                <span class="keywordflow">throw</span> std::invalid_argument(<span class="stringliteral">&quot;create_Gf error: graph must not be nullptr!&quot;</span>);</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            <span class="keywordflow">if</span>(graph-&gt;matrix.invalid_weight!=0)</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                <span class="keywordflow">throw</span> std::invalid_argument(<span class="stringliteral">&quot;create_Gf error: graph invalid weight must be 0!&quot;</span>);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;            <span class="keywordtype">int</span> new_invalid_weight=0;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            std::shared_ptr&lt;GraphType&gt; new_graph=std::make_shared&lt;GraphType&gt;(new_invalid_weight);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            <span class="comment">//*************  创建新图的顶点  ******************</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;            <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;GraphType::NUM;i++)</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;            {</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;                <span class="keyword">auto</span> vertex=graph-&gt;vertexes.at(i);</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;                <span class="keywordflow">if</span>(vertex)</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                    new_graph-&gt;add_vertex(vertex-&gt;key,vertex-&gt;id);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            }</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            <span class="comment">//**********   创建新图的边  ***********************</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;            std::vector&lt;EdgeTupleType&gt; new_edges;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;GraphType::NUM;i++)</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0;j&lt;GraphType::NUM;j++)</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;                {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;                   <span class="keywordflow">if</span>(i==j) <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;                   <span class="keywordflow">if</span>(!graph-&gt;vertexes[i]||!graph-&gt;vertexes[j]) <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;                   <span class="keywordflow">if</span>(graph-&gt;has_edge(i,j)) <span class="comment">//(u,v)属于E</span></div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                       new_edges.push_back(std::make_tuple(i,j,graph-&gt;weight(i,j)-flow[i][j]));</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;                   <span class="keywordflow">else</span> <span class="keywordflow">if</span>(graph-&gt;has_edge(j,i))  <span class="comment">//(v,u)属于E</span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                       new_edges.push_back(std::make_tuple(i,j,flow[j][i]));</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;                }</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;            new_graph-&gt;add_edges(new_edges.begin(),new_edges.end());</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;            <span class="keywordflow">return</span> new_graph;</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;        }</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;        <span class="keyword">template</span>&lt;<span class="keyword">typename</span> GraphType&gt; std::array&lt;std::array&lt;typename GraphType::EWeightType,GraphType::NUM&gt;,GraphType::NUM&gt;</div>
<div class="line"><a name="l00178"></a><span class="lineno"><a class="line" href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#a23a29754883e1edd7bd95a76634444a2">  178</a></span>&#160;        <a class="code" href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#a23a29754883e1edd7bd95a76634444a2">ford_fulkerson</a>(<span class="keyword">const</span> std::shared_ptr&lt;GraphType&gt; graph,<span class="keyword">typename</span> GraphType::VIDType src,<span class="keyword">typename</span> GraphType::VIDType dst)</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;        {</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;            <span class="keyword">typedef</span> <span class="keyword">typename</span> GraphType::EWeightType EWeightType;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;            <span class="keyword">typedef</span> <span class="keyword">typename</span> GraphType::VIDType VIDType;</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;            <span class="keyword">typedef</span> std::array&lt;std::array&lt;EWeightType,GraphType::NUM&gt;,GraphType::NUM&gt; MatrixType;</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;            <span class="keyword">typedef</span> std::function&lt;void(VIDType v_id)&gt; ActionType;</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;            <span class="keywordflow">if</span>(!graph)</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;                <span class="keywordflow">throw</span> std::invalid_argument(<span class="stringliteral">&quot;ford_fulkerson error: graph must not be nullptr!&quot;</span>);</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;            <span class="keywordflow">if</span>(src&lt;0||src&gt;=GraphType::NUM||dst&lt;0||dst&gt;=GraphType::NUM)</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;                <span class="keywordflow">throw</span> std::invalid_argument(<span class="stringliteral">&quot;ford_fulkerson error:id must &gt;=0 and &lt;N.&quot;</span>);</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;            <span class="keywordflow">if</span>(!graph-&gt;vertexes.at(src) || !graph-&gt;vertexes.at(dst))</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;                <span class="keywordflow">throw</span> std::invalid_argument(<span class="stringliteral">&quot;ford_fulkerson error: vertex of id does not exist.&quot;</span>);</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;            ActionType empty_action=[](VIDType v_id){};</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;            <span class="comment">//********** 初始化 flow 为全 0 **********</span></div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;            MatrixType flow;</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;            <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;GraphType::NUM;i++)</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0;j&lt;GraphType::NUM;j++)</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;                    flow[i][j]=0;</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;            std::shared_ptr&lt;GraphType&gt; Gf;</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;            <span class="keywordflow">while</span>(<span class="keyword">true</span>)</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;            {</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;                Gf=<a class="code" href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#acc8cd65d7cf2d584f86cfd92494bdbf4">create_Gf</a>(graph,flow); <span class="comment">//创建残余网络</span></div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;                <span class="comment">//************ 寻找增广路径  *************</span></div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;                breadth_first_search&lt;GraphType&gt;(Gf,src,empty_action,empty_action);</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;                <span class="keyword">auto</span> path=<a class="code" href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#a1581960f77507024b39572aeb6d1fbd6">get_path</a>(Gf-&gt;vertexes.at(src),Gf-&gt;vertexes.at(dst));</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;                <span class="keywordflow">if</span>(path.size()==0) <span class="keywordflow">break</span>;  <span class="comment">//不存在增广路径</span></div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;                EWeightType cf=unlimit&lt;EWeightType&gt;();</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=1;i&lt;path.size();i++)  <span class="comment">//求取增广路径的残余容量</span></div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;                {</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;                    <span class="keyword">auto</span> u=path[i-1];</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;                    <span class="keyword">auto</span> v=path[i];</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;                    <span class="keyword">auto</span> w=Gf-&gt;weight(u,v);</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;                    <span class="keywordflow">if</span>(w&lt;cf) cf=w;</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;                }</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;                <span class="comment">//*****************  更新流矩阵  ***************</span></div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=1;i&lt;path.size();i++)</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;                {</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;                    <span class="keyword">auto</span> u=path[i-1];</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;                    <span class="keyword">auto</span> v=path[i];</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;                    <span class="keywordflow">if</span>(graph-&gt;has_edge(u,v)) <span class="comment">//(u,v)属于E</span></div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;                        flow[u][v]+=cf;</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;                    <span class="keywordflow">else</span> <span class="keywordflow">if</span>(graph-&gt;has_edge(v,u))  <span class="comment">//(v,u)属于E</span></div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;                        flow[v][u]-=cf;</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;                }</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;            }</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;            <span class="keywordflow">return</span> flow;</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;        }</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    }</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;}</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;<span class="preprocessor">#endif // FORDFULKERSON</span></div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;</div>
<div class="ttc" id="namespace_introduction_to_algorithm_1_1_graph_algorithm_html_acc8cd65d7cf2d584f86cfd92494bdbf4"><div class="ttname"><a href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#acc8cd65d7cf2d584f86cfd92494bdbf4">IntroductionToAlgorithm::GraphAlgorithm::create_Gf</a></div><div class="ttdeci">std::shared_ptr&lt; GraphType &gt; create_Gf(const std::shared_ptr&lt; GraphType &gt; graph, std::array&lt; std::array&lt; typename GraphType::EWeightType, GraphType::NUM &gt;, GraphType::NUM &gt; &amp;flow)</div><div class="ttdoc">create_Gf：根据指定流网络生成一个残余网络。算法导论26章26.2节 </div><div class="ttdef"><b>Definition:</b> <a href="fordfulkerson_8h_source.html#l00054">fordfulkerson.h:54</a></div></div>
<div class="ttc" id="header_8h_html"><div class="ttname"><a href="header_8h.html">header.h</a></div></div>
<div class="ttc" id="namespace_introduction_to_algorithm_1_1_graph_algorithm_html_a1581960f77507024b39572aeb6d1fbd6"><div class="ttname"><a href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#a1581960f77507024b39572aeb6d1fbd6">IntroductionToAlgorithm::GraphAlgorithm::get_path</a></div><div class="ttdeci">std::vector&lt; typename VertexType::VIDType &gt; get_path(const std::shared_ptr&lt; VertexType &gt; v_from, const std::shared_ptr&lt; VertexType &gt; v_to)</div><div class="ttdoc">get_path：获取两个顶点之间的路径 </div><div class="ttdef"><b>Definition:</b> <a href="header_8h_source.html#l00141">header.h:141</a></div></div>
<div class="ttc" id="namespace_introduction_to_algorithm_1_1_graph_algorithm_html_a23a29754883e1edd7bd95a76634444a2"><div class="ttname"><a href="namespace_introduction_to_algorithm_1_1_graph_algorithm.html#a23a29754883e1edd7bd95a76634444a2">IntroductionToAlgorithm::GraphAlgorithm::ford_fulkerson</a></div><div class="ttdeci">std::array&lt; std::array&lt; typename GraphType::EWeightType, GraphType::NUM &gt;, GraphType::NUM &gt; ford_fulkerson(const std::shared_ptr&lt; GraphType &gt; graph, typename GraphType::VIDType src, typename GraphType::VIDType dst)</div><div class="ttdoc">ford_fulkerson：最大流的ford_fulkerson算法。算法导论26章26.2节 </div><div class="ttdef"><b>Definition:</b> <a href="fordfulkerson_8h_source.html#l00178">fordfulkerson.h:178</a></div></div>
<div class="ttc" id="namespace_introduction_to_algorithm_html"><div class="ttname"><a href="namespace_introduction_to_algorithm.html">IntroductionToAlgorithm</a></div><div class="ttdoc">Namespace of IntrodunctionToAlgorithm. </div><div class="ttdef"><b>Definition:</b> <a href="longest__common__subsequence_8h_source.html#l00024">longest_common_subsequence.h:24</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_8ed9dba4cd616b67da9b1338594e34e0.html">src</a></li><li class="navelem"><a class="el" href="dir_aa0a5ddea82682e3e6fbdbaa3337ee0e.html">graph_algorithms</a></li><li class="navelem"><a class="el" href="dir_a4fbac2a12224e4d8b34a92a8974f6d5.html">max_flow</a></li><li class="navelem"><a class="el" href="dir_1fe642ec8116a9c108d1c569eba06e08.html">ford_fulkerson</a></li><li class="navelem"><a class="el" href="fordfulkerson_8h.html">fordfulkerson.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.10 </li>
  </ul>
</div>
</body>
</html>
